package com.bright.ghj.user.cas;

import com.bright.ghj.user.properties.CasProperties;
import org.springframework.security.cas.web.authentication.ServiceAuthenticationDetails;

import java.util.Objects;

/**
 * @Author txf
 * @Date 2025/11/8 16:46
 * @Description
 */
public class CasServiceAuthenticationDetails implements ServiceAuthenticationDetails {

    private String serviceUrl;
    private CasProperties casProperties;

    public CasServiceAuthenticationDetails(String serviceUrl, CasProperties casProperties) {
        this.serviceUrl = serviceUrl;
        this.casProperties = casProperties;
    }

    @Override
    public String getServiceUrl() {
        if (Objects.isNull(serviceUrl)) {
            return casProperties.getAppServerUrl().get(0) + casProperties.getAppLoginUrl();
        } else {
            return serviceUrl;
        }

    }
}
